# import time
#
#
# from selenium import webdriver
#
# driver = webdriver.Chrome()
# driver.maximize_window()
# driver.implicitly_wait(30)
# driver.get("https://www.baidu.com")
# driver.find_element_by_id("kw").send_keys("测试用例")
# su = driver.find_element_by_id("su")
#
# su.click()
# time.sleep(3)
# title = driver.find_element_by_xpath("//*[@id='su']")
# print(title.is_displayed())
# s = title.get_attribute('value')
# time.sleep(3)
# print(s)
#
# driver.quit()
# requests.get("https://www.baidu.com", wd="测试用例")

# a = [1, 2]
# print(id(a))
# b = [1, 2]
# a.append(3)
# print(id(a), id(b))
# import re
# a = 'not 404 found 张三 99 深圳'
# res = re.findall("\d+|[a-zA-Z]+", a)
# s = a.split(" ")
# st = ""
# for i in res:
#     if i in s:
#         s.remove(i)
#
# print(' '.join(s))

# l = [0, 1, 2, 3]
# print(id(l), id(l[0]))
# a = 140736778449712 / 464769409544
# print(a)
import threading
import time

import requests

urls = [f"https://www.cnblogs.com/#p{page}" for page in range(1, 51)]

def craw(url):

    r = requests.get(url)
    print(url, len(r.text))

def single_thread():
    for url in urls:
        craw(url)

def multi_thread():

    threads = []
    for url in urls:
        threads.append(threading.Thread(target=craw, args=(url,)))

    for thread in threads:
        thread.start()

    for thread in threads:
        thread.join()


if __name__ == '__main__':
    single_start = time.time()
    single_thread()
    single_end = time.time()
    print(single_end - single_start)

    multi_start = time.time()
    multi_thread()
    multi_end = time.time()
    print(multi_end - multi_start)
